<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
	<head>
		<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
		<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
		<script type="text/javascript">
	function checkAll(val) {
		//alert(val);
		if (val)
			$('input[name=ids]').each(function() {
				$(this).attr('checked', true);
			})
		else
			$('input[name=ids]').each(function() {
				$(this).attr('checked', false);
			})
	}
	function gotopage() {
		var page = $('#topage').val();
		var url = '${approot}/admin/prepaid/list/page/' + page;
		// alert(url);
		window.location.href = url;
	}
	//清空恢复表单原始数据
	function formreset() {
		$("input[type=text]").val("");
		$("#type").val("0");
	}

	//批量删除
	function delete_batch() {
		var count = 0;
		$('input[name=ids]:checked').each(function() {
			count = count + 1;
		})
		if (count == 0) {
			alert("请至少选中一条记录");
			return false;
		} else {
			var ids = "";
			$("input[name='ids']:checked").each(function() {
				ids = ids + $(this).val() + "_";
			})
			var url = '${approot}/admin/prepaid/delete_batch/' + ids;
			//alert(url);
			//window.location.href=url;

		}

	}

	function delete_prepaid(id){
		if(confirm("您确认对此客户进行销户处理吗？如果确定请继续。")){
			$.ajax( {
				url : '${approot}/admin/prepaidDelete/delete/'+id,
				dataType : 'json',
				contentType : 'application/json',
				data : null,
				type : 'post',
				beforeSend : function() {
					// $('#main').disabled='true';
				},
				error : function(request) {
					alert(S);
				},
				success : function(data) {
					if (data.msg == "error") {
						alert('销户失败，系统异常');
					}
					if (data.msg == "succ") {
						alert('销户成功。');
						window.location.reload();
					}
				}
			});
		}
	}
//	function to_pay_money(id){
//		window.open('${approot}/admin/excerpt/to_pay_money/'+id,'_blank','height=600,width=800,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no,left=200,top=200');
//	}
</script>
	</head>
	<body style="background: #E8F5FE; padding: 15px 18px;" class="scroll_r">

		<form method="post" action="${approot}/admin/prepaid/list/form/0"
			id="prepaidBean">

			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" id="add_tab">

				<tr>
				<!-- 	<th>
						用户编号：
					</th>
					<td>
					  	<input type="text" id="number" name="number"
							value="${prepaidBean.number}" />
					</td> -->
					<th>
						用户名：
					</th>
					<td>
						<input type="text" id="name" name="name"
							value="${prepaidBean.name}" />
					</td>
					<th>
						地址：
					</th>
					<td>
						<input type="text" id="addr" name="addr"
							value="${prepaidBean.addr}" />
					</td>
				<!--	<th>
						用气类型：
					</th>
					<td>
						<select name="type" id="type">
							<option value="">
								全部
							</option>
							<option value="0"
								<c:if test="${excerptBean.type==0}">selected="selected"</c:if>>
								天然气
							</option>
							<option value="1"
								<c:if test="${excerptBean.type==1}">selected="selected"</c:if>>
								液化气
							</option>
							<option value="2"
								<c:if test="${excerptBean.type==2}">selected="selected"</c:if>>
								商业气
							</option>
						</select>
					</td>
					<th>
						状态：
					</th>
					<td>
						<select name="status" id="status">
							<option value="">
								全部
							</option>
							<option value="0"
								<c:if test="${excerptBean.status==0}">selected="selected"</c:if>>
								未缴费
							</option>
							<option value="1"
								<c:if test="${excerptBean.status==1}">selected="selected"</c:if>>
								已缴费
							</option>
						</select>
					</td>-->
					<th>
						开户时间：
					</th>
					<td>
						<input type="text" id="startTime" name="startTime"
							value="${prepaidBean.strStartDate}" class="Wdate"
							onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
					</td>
					<th>
						至
					</th>
					<td>
						<input type="text" id="endTime" name="endTime"
							value="${prepaidBean.strEndDate}" class="Wdate"
							onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
					</td>
				</tr>
				<tr>
					<td colspan="8" style="text-align: center">
						<input type="submit" class="but" value="开始查询">
						<input type="button" class="but" onclick="formreset()" value="重置条件">
				<!-- 	<c:if test="${fn:length(page.items)>0}">
							<input type="button" class="but" onclick="location.href='${approot}/admin/excel/exportExcel'" value="导出">
						</c:if> -->	
					</td>

				</tr>

			</table>
		</form>


		<c:choose>
			<c:when test="${fn:length(page.items)<1}">
				<div align="center">
					<font color='red'>对不起,暂时没有找到符合条件的数据!</font>
				</div>
			</c:when>
			<c:otherwise>
				<table border="0" cellpadding="" cellspacing="1" align="center" width="92%" id="web_tab">
					
					<tr>
						
						<th>
							客户编号
						</th>
						<th>
							姓名
						</th>
						<th>
							地址
						</th>
						<th>
							用气类型
						</th>
						<th>
							气价
						</th>
						<th>
							气表类型
						</th>
						<th>
							联系电话
						</th>
						<th>
							密码
						</th>
						<th>
							备注
						</th>
						<th>
							创建日期
						</th>
						<th>
							表名
						</th>
						<th>
							操作
						</th>
					</tr>
					<c:forEach var="prepaid" items="${page.items}">
						<tr>
							<td>
								${prepaid.prepaidId}
							</td>
							<td>
								${prepaid.prepaidName}
							</td>
							<td>
								${prepaid.prepaidAddress}
							</td>
							<td>
								${prepaid.prepaidType }
							</td>
							<td>
								${prepaid.prepaidPrice}
							</td>
							<td>
								${prepaid.prepaidMeterType}
							</td>
							<td>
								${prepaid.prepaidTel}
							</td>
							<td>
								${prepaid.password}
							</td>
							<td>
								${prepaid.remark}
							</td>
							
							<td>
								<fmt:formatDate value="${prepaid.createTime}"
									pattern="yyyy-MM-dd HH:mm:ss" />
							</td>
							<td>
								${prepaid.meterName}
							</td>
							<td>
							<a href="${approot}/admin/prepaid/view/${prepaid.prepaidId}">详细</a>&nbsp;&nbsp;<a href="${approot}/admin/prepaid/to_edit/${prepaid.prepaidId}">编辑</a>&nbsp;&nbsp;<a href="#" onclick="delete_prepaid('${prepaid.prepaidId}')">销户</a>
							</td>
						</tr>
					</c:forEach>
				</table>
				<table border="0" cellpadding="0" cellspacing="1" width="92%"
					align="center">
					<tr>
						<td align="left">
							共有
							<font color='red'>${page.totalCount}</font> 条记录，当前第
							<font color='red'>${page.currentPage}</font>页，共
							<font color='red'>${page.pageCount}</font>页
						</td>
						<td align="right">
							转到
							<select name="topage" id="topage" onchange="gotopage();">
								<c:forEach var="ind" items="${page.pages}">
									<option value="${(ind-1)*page.pageSize}"
										<c:if test="${ind==page.currentPage}">selected="selected"</c:if>>
										${ind}
									</option>
								</c:forEach>
							</select>

							<button class="but"
								onclick="window.location.href='${approot}/admin/prepaid/list/page/${page.firstIndex}'">
								首页
							</button>
							<button class="but"
								onclick="window.location.href='${approot}/admin/prepaid/list/page/${page.previousIndex}'">
								上一页
							</button>
							<c:forEach items="${page.showpages}" var="ind">
								<c:if test="${ind!=0}">
									<a
										href="${approot}/admin/prepaid/list/page/${(ind-1)*page.pageSize}">${ind}</a>
								</c:if>
							</c:forEach>
							<button class="but"
								onclick="window.location.href='${approot}/admin/prepaid/list/page/${page.nextIndex}'">
								下一页
							</button>
							<button class="but"
								onclick="window.location.href='${approot}/admin/prepaid/list/page/${page.lastIndex}'">
								末页
							</button>
						</td>
					</tr>
				</table>
			</c:otherwise>
		</c:choose>
	</body>
</html>
